import { Injectable } from '@angular/core';
import { HttpClient } from '../../../providers/httpClient';
import { Config } from '../../../providers/config';
import _ from "lodash";

@Injectable()
export class CirculateService {
	constructor(
		public httpClient: HttpClient,
		public config: Config,
	) { }

  getListDatas(condition) {

    let postBody = {
      "module": "OAServer",
      "method": "getCirculateQueryData",
      "params": {
        "fund_code": condition.fund_code,
        "vc_user_p": "",
        "l_fut_date_p": _.replace(condition.l_fut_date_p, /-/g, ""),
        "l_days_p": condition.l_days_p,
        "en_value0_p": condition.en_value0_p + "0000"
      }
    };
    return this.httpClient.post(postBody);
  }

	getL_fut_date_p(l_date) {
	  if (l_date){
	    l_date = _.replace(l_date, /-/g, "");
    }

    let postBody = {
      "module": "KSB",
      "method": "TRA_002_0051",
      "params": {
        "l_date": l_date,
        "l_day": "3",
        "c_date_type": ""
      }
    };
    return this.httpClient.post(postBody);
  }

  getFundList(loginid, fundType) {

    let postBody = {
      "module": "OAServer",
      "method": "getFundList",
      "params": {
        "vc_user": loginid,
        "c_invest_style": fundType
      }
    };

    return this.httpClient.post(postBody);
  }
}
